<#include "../common/layout/__mainlayout.html">
    <#include "../common/__pagination.html">

        <!--设置面包屑-->
        <#assign pageBreadCrumbs>
            <li class="active"><a href="#">广告管理</a></li>
            <li class="active">广告内容管理</li>
        </#assign>
        <#assign pageCss>
            <!-- page specific plugin styles -->
            <link rel="stylesheet" href="${ctx}/static/admin/assets/css/jquery-ui.custom.css"/>
            <link rel="stylesheet" href="${ctx}/static/admin/assets/css/chosen.css"/>
            <link rel="stylesheet" href="${ctx}/static/admin/assets/css/datepicker.css"/>
        </#assign>

        <#assign pageJavascript>
            <script type="text/javascript">
                $(document).ready(function () {
                    $('[data-rel=tooltip]').tooltip();

                    if (!ace.vars['touch']) {
                        $('.chosen-select').chosen({allow_single_deselect: true});
                    }

                    // 清除远程modal数据
                    $("#editModal").on("hidden.bs.modal", function () {
                        $(this).removeData("bs.modal");
                    });
                    // 删除按钮
                    $("a.delete").on(ace.click_event, function (e) {
                        var currentA = this;
                        e.preventDefault();
                        bootbox.confirm({
                                    message: "确定删除该广告内容?",
                                    buttons: {
                                        confirm: {
                                            label: "确定",
                                            className: "btn-primary btn-sm"
                                        },
                                        cancel: {
                                            label: "取消",
                                            className: "btn-sm"
                                        }
                                    },
                                    callback: function (result) {
                                        if (result) {
                                            url = $(currentA).attr("href");
                                            $.get(url, { },function(data){
                                                if(data){
                                                    window.location.href=window.location.href;
                                                }
                                            });
                                        }
                                    }
                                }
                        );
                    });

                    // 隐藏按钮
                    $("a.fackDelete").on(ace.click_event, function (e) {
                        var currentA = this;
                        e.preventDefault();
                        bootbox.confirm({
                                    message: "确定隐藏该广告内容?",
                                    buttons: {
                                        confirm: {
                                            label: "确定",
                                            className: "btn-primary btn-sm"
                                        },
                                        cancel: {
                                            label: "取消",
                                            className: "btn-sm"
                                        }
                                    },
                                    callback: function (result) {
                                        if (result) {
                                            url = $(currentA).attr("href");
                                            $.get(url, { },function(data){
                                                if(data){
                                                    window.location.href=window.location.href;
                                                }
                                            });
                                        }
                                    }
                                }
                        );
                    });

                    // 显示按钮
                    $("a.showtype").on(ace.click_event, function (e) {
                        var currentA = this;
                        e.preventDefault();
                        bootbox.confirm({
                                    message: "确定显示该广告内容?",
                                    buttons: {
                                        confirm: {
                                            label: "确定",
                                            className: "btn-primary btn-sm"
                                        },
                                        cancel: {
                                            label: "取消",
                                            className: "btn-sm"
                                        }
                                    },
                                    callback: function (result) {
                                        if (result) {
                                            url = $(currentA).attr("href");
                                            $.get(url, { },function(data){
                                                if(data){
                                                    window.location.href=window.location.href;
                                                }
                                            });
                                        }
                                    }
                                }
                        );
                    });
                });
            </script>
        </#assign>

        <@mainlayout pageBreadCrumbs=pageBreadCrumbs pageCss=pageCss pageJavascript=pageJavascript
        currentMenu="adFlag-adItemFlag">
        <div class="row">
            <div class="col-xs-12">
            <form id="searchForm" class="form-search form-inline" action="/admin/ad/adItemList.do">
                <label>广告位名称:</label><input type="text" id="adSpaceName" name="adSpaceName" class="input-sm input-small"
                                            value="${query.adSpaceName!}"/>&nbsp;
                <label>广告标题:</label><input type="text" id="adItemTitle" name="adItemTitle" class="input-sm input-small"
                                           value="${query.adItemTitle!}"/>&nbsp;
                <input type="submit" id="searchBtn" class="btn btn-sm btn-primary" value="查询"/>&nbsp;
                <a href="${ctx}/admin/ad/viewAdItem.do?origin=adItemList" class="btn btn-sm btn-warning" data-toggle="modal"
                   data-target="#editModal"><i class="ace-icon fa fa-plus"></i>添加</a>

            <table id="adItemTable" class="table table-striped table-bordered table-hover">
                <thead>
                <tr>
                    <th width="40" align="center">广告内容编号</th>
                    <th width="100" align="left">广告标题</th>
                    <th width="70" align="left">广告位名称</th>
                    <th width="70" align="left">创建时间</th>
                    <th width="60" align="left">资源类型</th>
                    <th width="30" align="center">资源编号</th>
                    <th width="80" align="center">排序</th>
                    <th width="70" align="center">广告周期</th>
                    <th width="40" align="center">操作</th>
                </tr>
                </thead>
                <tbody>
                <#if adItemList.listData??>
                    <#list adItemList.listData as adItem>
                        <tr>
                            <td>${adItem.id!}</td>
                            <td>${adItem.adItemTitle!}</td>
                            <td>${adItem.adSpaceName!}</td>
                            <td>
                                ${adItem.createTimeShow!}
                            </td>
                            <td>
                                <#if adItem.resourceType == 1>
                                    软件详情
                                    <#elseif   adItem.resourceType = 2>
                                        软件分类
                                        <#elseif  adItem.resourceType = 3>
                                            专题
                                            <#elseif  adItem.resourceType = 4>
                                                外链
                                                <#else>
                                </#if>
                            </td>
                            <td>${adItem.resourceValue!}</td>
                            <td>${adItem.sortIndex!}</td>
                            <td>${adItem.startTimeShow!} - ${adItem.expiredTimeShow!}</td>
                            <td>
                                <div class="hidden-sm hidden-xs action-buttons">
                                    <a class="green tooltip-success edit" href="${ctx}/admin/ad/viewAdItem.do?adItemId=${adItem.id!}"   data-rel="tooltip" title="修改" data-toggle="modal" data-target="#editModal"><span class="label label-success">修改</span></a>
                                    <#if adItem.state == 1>
                                        <a class="red tooltip-warning fackDelete"   href="${ctx}/admin/ad/changeAdItem.do?adItemId=${adItem.id!}&state=0"  data-rel="tooltip" title="隐藏"><span class="label label-warning">隐藏</span></a>
                                        <#elseif   adItem.state == 0>
                                            <a class="red tooltip-warning showtype"   href="${ctx}/admin/ad/changeAdItem.do?adItemId=${adItem.id!}&state=1"  data-rel="tooltip" title="显示"><span class="label label-warning">显示</span></a>
                                    </#if>
                                    <a class="red tooltip-error delete"  href="${ctx}/admin/ad/deleteAdItem.do?adItemId=${adItem.id!}&state=-1"   data-rel="tooltip" title="删除"><span class="label label-danger">删除</span></a>
                                </div>

                                <div class="hidden-md hidden-lg">
                                    <div class="inline position-relative">
                                        <button class="btn btn-minier btn-yellow dropdown-toggle" data-toggle="dropdown"
                                                data-position="auto">
                                            <i class="ace-icon fa fa-caret-down icon-only bigger-120"></i>
                                        </button>

                                        <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                                            <li><a href=${ctx}/admin/ad/viewAdItem.do?adItemId=${adItem.id!}"   class="tooltip-success edit" data-rel="tooltip" title="修改"  data-toggle="modal" data-target="#editModal"> <span class="label label-success">修改</span>></a>
                                            </li>
                                            <li><a href="${ctx}/admin/ad/changeAdItem.do?adItemId=${adItem.id!}"   class="tooltip-warning fackDelete" data-rel="tooltip" title="隐藏"  data-toggle="modal" data-target="#editModal"> <span class="label label-warning">隐藏</span></a></li>
                                            <li><a href="${ctx}/admin/ad/deleteAdItem.do?adSpaceId=${adItem.id!}"   class="tooltip-error delete" data-rel="tooltip" title="删除"> <span class="label label-danger">删除</span></a>
                                            </li>

                                        </ul>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </#list>
                </#if>
                </tbody>
            </table>
            <@pagination adItemList!/>
            </form>
        </div>
        </div>

        <div id="editModal" class="modal fade">
            <div class="modal-dialog">
                <div class="modal-content">
                </div>
            </div>
        </div>
    </@mainlayout>